<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:m="http://www.ol4jsf.org"
	xmlns:a4j="http://richfaces.org/a4j">

	<h:panelGroup id="attachedFilesTable">
		<h:panelGroup rendered="#{empty operationPermitHelper.attachedFiles}">
			<div align="center">
				<br/>
				<h:outputText value="#{messages['intro2.nodocsattached']}"/>
			</div>
		</h:panelGroup>
	
		<h:panelGroup rendered="#{not empty operationPermitHelper.attachedFiles}">
			<rich:dataTable id="attachedFilesTableData" value="#{operationPermitHelper.attachedFiles}" var="file" rowKeyVar="row">
				<rich:column>
					<f:facet name="header">#{messages['intro2.description']}</f:facet>
					<h:outputText value="#{file.descripcion}"/>
				</rich:column>
		
				<rich:column>
					<f:facet name="header">#{messages['txt.type']}</f:facet>
					<h:outputText value="#{messages[file.adminSourceType.name()]}"/>
				</rich:column>
		
				<rich:column>
					<f:facet name="header">#{messages['intro2.filename']}</f:facet>
					<h:inputText readonly="true" value="#{file.fileName}" />
				</rich:column>
		
				<rich:column>
					<h:commandLink action="/seam/resource/documentviewer" target="_blank">
						<f:setPropertyActionListener target="#{documentViewer.archiveId}" value="#{file.id}"/>
						<f:setPropertyActionListener target="#{documentViewer.forceDownload}" value="#{false}"/>
						<h:outputText value="#{messages['viewtransaction.viewattacheddoc']}"/>
					</h:commandLink>
				</rich:column>
		
				<rich:column rendered="#{not readonly}">
					<a4j:commandLink
						value="#{messages['intro2.edit']}"
						oncomplete="#{rich:component('attachFilePanel')}.show()"
						reRender="#{reRenderAfterEdit}">
						<f:setPropertyActionListener target="#{operationPermitHelper.selectedFile}" value="#{file}"/>
						<f:setPropertyActionListener target="#{operationPermitHelper.editMode}" value="1"/>
						<f:setPropertyActionListener target="#{operationPermitHelper.currentRow}" value="#{row}"/>
					</a4j:commandLink>
					<h:outputText value="  "/>
					<a4j:commandLink rendered="#{not deleteDisabled}"
						value="#{messages['intro2.delete']}"
						action="#{operationPermitHelper.deleteSelectedFile}"
						reRender="attachedFilesTable">
						<f:setPropertyActionListener target="#{operationPermitHelper.currentRow}" value="#{row}"/>
					</a4j:commandLink>
				</rich:column>
			</rich:dataTable>
		</h:panelGroup>
		
		<h:panelGroup rendered="#{not readonly}">
			<br />
			<a4j:commandLink value="#{messages['intro2.add']}"
					oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('attachFilePanel')}.show()" reRender="info">
				<f:setPropertyActionListener value="0" target="#{operationPermitHelper.editMode}" />
			</a4j:commandLink>
		</h:panelGroup>
		
	</h:panelGroup>	
</ui:composition>
